Skip to content

TRPL: attributes & conditional compilation #24673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2015

Conversation

steveklabnik
Copy link
Member

These can nest arbitrarily:

```rust
#[cfg(any(not(unix), all(macos, target_arch = "powerpc")))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macos here should be target_os = "macos"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@alexcrichton
Copy link
Member

Could this also make a mention of the cfg! syntax extension? I would personally recommend using cfg! whenever possible over #[cfg] as the code will be guaranteed to at least compile on all platforms.

@steveklabnik
Copy link
Member Author

@alexcrichton i have not actually used cfg!. Do we have any examples lying around?

@alexcrichton
Copy link
Member

There's some example usage in backtrace.rs, specifically here and here

@steveklabnik
Copy link
Member Author

Example added. neat!

@Ms2ger
Copy link
Contributor

Ms2ger commented Apr 22, 2015

lgtm

therefore, which code gets compiled. Let’s take this code:

```rust
#[cfg(feature = foo)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this'll need to be feature = "foo" (with the quotes)

@alexcrichton
Copy link
Member

r=me with a minor nit, thanks!

@steveklabnik
Copy link
Member Author

@bors: r=alexcrichton rollup

@bors
Copy link
Collaborator

bors commented Apr 22, 2015

📌 Commit a5ae4cc has been approved by alexcrichton

Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 22, 2015
@bors bors merged commit a5ae4cc into rust-lang:master Apr 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants